home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 1.toast / pc / sample code / files / is pc exchange installed / ispcexchangeinstalled.c next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  2.4 KB  |  101 lines

  1. /*
  2.     File:        IsPCExchangeInstalled.c
  3.     
  4.     Description:This snippet demonstrates the check for the existence of PC Exchange.
  5.                 The FSMGlueLib.o file is available on the MacOS SDK CD in the File
  6.                 System Manager Libraries folder.
  7.  
  8.  
  9.     Author:        JL
  10.  
  11.     Copyright:     Copyright: © 1996-1999 by Apple Computer, Inc.
  12.                 all rights reserved.
  13.     
  14.     Disclaimer:    You may incorporate this sample code into your applications without
  15.                 restriction, though the sample code has been provided "AS IS" and the
  16.                 responsibility for its operation is 100% yours.  However, what you are
  17.                 not permitted to do is to redistribute the source as "DSC Sample Code"
  18.                 after having made changes. If you're going to re-distribute the source,
  19.                 we require that you make it clear in the source that the code was
  20.                 descended from Apple Sample Code, but that you've made changes.
  21.     
  22.     Change History (most recent first):
  23.                 6/25/99    Updated for Metrowerks Codewarror Pro 2.1(KG)
  24.  
  25. */
  26.  
  27. #include <Gestalt.h>
  28. #include <FSM.h>
  29.  
  30. static    Boolean    HasFSM(void);
  31. Boolean    IsMacPCExchangeInstalled(void);
  32.  
  33.  
  34. /*
  35. **    HasFSM determines if the File System Manager is available.
  36. */
  37. static    Boolean    HasFSM(void)
  38. {
  39.     long    response;
  40.     Boolean    result;
  41.     
  42.     result = false;
  43.     
  44.     /* Make sure the File System Manager is installed */
  45.     if ( Gestalt(gestaltFSAttr, &response) == noErr )
  46.     {
  47.         if ( (response & (1L << gestaltHasFileSystemManager)) != 0 )
  48.         {
  49.             result = true;
  50.         }
  51.     }
  52.     
  53.     return ( result );
  54. }
  55.  
  56. /*****************************************************************************/
  57.  
  58. /*
  59. **    IsMacPCExchangeInstalled determines if Macintosh PC Exchange has installed
  60. **    the MS-DOS foreign file system.
  61. */
  62. Boolean    IsMacPCExchangeInstalled(void)
  63. {
  64.     enum
  65.     {
  66.         kMacPCExchangeFSID = 0x4953    /* file system ID of Macintosh PC Exchange's
  67.                                         MS-DOS file system */
  68.     };
  69.     Boolean    result;
  70.     short    bufSize;    /* The size of the FSDRec */
  71.     FSDRec    theFSDRec;    /* The FSDRec */
  72.     
  73.     result = false;     /* default to no Macintosh PC Exchange */
  74.     
  75.     /* Make sure the File System Manager is available */
  76.     if ( HasFSM() )
  77.     {
  78.         bufSize = sizeof(FSDRec);
  79.         if ( GetFSInfo(fsmGetFSInfoByFSID, kMacPCExchangeFSID, &bufSize, &theFSDRec) == noErr )
  80.         {
  81.             result = true;
  82.         }
  83.     }
  84.     
  85.     return ( result );
  86. }
  87.  
  88. /*****************************************************************************/
  89.  
  90. /* Test code */
  91. void    main(void)
  92. {
  93.     if ( IsMacPCExchangeInstalled() )
  94.     {
  95.         DebugStr("\pMacintosh PC Exchange is installed");
  96.     }
  97.     else
  98.     {
  99.         DebugStr("\pMacintosh PC Exchange is NOT installed");
  100.     }
  101. }